Random Number Generator

TPT can generate random values for the test modeling when using either the function
random() or the equivalence class macro .random in the value field of a test step.

The settings are identical for both, the function and the macro.

Random Number Generation section

 

Configure behavior of the random() function

New random value for each test run

Whenever you rerun a test, a new random value is generated.

Fix per test case

The random values are created once for the test steps. When you rerun the test case, the same random values are used. For example, if a test case TC1 has the same test steps as TC2, then the random values will nevertheless be different.

Fix value

The fix value is used as an initial seed for the calculation of the random value. It must be an integer. As long as you use the same random seed and do not change the test case, you will get the same random values.

For example, if a test case TC1 has the same test steps as TC2, then the random values in both test cases will be the same. The seeds used for the generation of the random value are saved in the test directory folder in the file testcase_information.xml as RandomSeedForRandom and RandomSeedForEC; see Data storage. Copy the saved seed from this file and paste it into the corresponding Fix value field to reuse it.

Random seed information in the testcase_information.xml file

Configure behavior '.random' values for equivalence classes

See option Configure behavior of the random() function.

Using the random() function

The values of the random() function is calculated at run time, thus the values will change in every time step. Select Once in the Channel step to set the value only at the first time cycle, see Step Type - Channel. The random value is a float value and lies by default between 0 and 1. To use higher values, multiply the random value, for example: 100*random(). To cast the random values to integers, type: (int32) 100*random().

Using the '.random' macro

Random values for equivalence classes are based on the specified equivalence class interval, see Equivalence Classes. The values of the .random macro is determined at compile time, thus the values will not change in every time step. To generate a random value for an equivalence class, you must type <signal>->ec.<interval>.random in the value field of the test step, for example my_channel->ec.INTERVAL1.random.

Equivalence classes may have a representative value. This representative value will be ignored when using the .random macro. When there is no representative value set, the value is always determined randomly based on the interval. Thus without a representative, my_channel->ec.INTERVAL1 does the same as my_channel->ec.INTERVAL1.random.

  no representative value set representative value set
EC1.INTERVAL1 random value representative value
EC1.INTERVAL1.random random value random value